let mongoose = require('mongoose');
let {dbUrl} = require('../config');
let Film = require('../models/film.js');

// 第一种连接方式

// mongoose.connect(testUrl, { useNewUrlParser: true });

mongoose.connect(dbUrl, {
  useNewUrlParser: true,
  useCreateIndex: true
});
(async () => {
  let films = await Film.find();
  films.forEach(async item => {
    item.poster = item.poster.replace(/^http/, 'https');
    item.coverurl = item.coverurl.replace(/^http/, 'https');
    item.videoUrl = item.videoUrl.replace(/^http/, 'https');
    await item.save();
  });
})();
